#include <stdio.h>

void* My_strncpy(char* dst, char* src, size_t num)
{
    while(*src && num)
    {
        num--;
        //将数据转按个数要求过去
        *dst++ = *src++;
    }
    while(num--)
    {
        *dst++ = '\0';
    }
}  

int main()
{
    char arr1[] = "abcde";
    char arr2[20] = {0};
    My_strncpy(arr2, arr1, 3);
    printf("%s", arr2);
    return 0;
}